﻿
/*----------------------------------------------------------------
 * 创建时间：2023/9/4 15:07:06
 * 作  者：wenlli 
 * 项  目：Minotaur.App.Core.Interceptors 
 * 描  述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时  间：
 * 修改说明：
 * 
 *----------------------------------------------------------------*/


using Castle.DynamicProxy;
using Mapster.Adapters;
using Minotaur.App.Core.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Minotaur.App.Core.Interceptors
{
    public class GlobalLogInterceptor : AsyncInterceptorBase, ICommonInterceptor
    {
        GlobalUserModel _userModel;
        IDbContext dbContext;

        public GlobalLogInterceptor(GlobalUserModel userModel, IDbContext dbContext)
        {
            _userModel = userModel;
            this.dbContext = dbContext;
        }

        protected override async Task InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func<IInvocation, IInvocationProceedInfo, Task> proceed)
        {
            var attribute = invocation.Method.GetCustomAttribute<GlobalLogAttribute>();
            if (attribute is null)
            {
                await proceed(invocation, proceedInfo);
                return;
            }
            await Before(invocation, proceedInfo);
            await proceed(invocation, proceedInfo);
            await After(invocation, proceedInfo);
        }

        private Task After(IInvocation invocation, IInvocationProceedInfo proceedInfo)
        {
            throw new NotImplementedException();
        }

        private Task Before(IInvocation invocation, IInvocationProceedInfo proceedInfo)
        {
            throw new NotImplementedException();
        }

        protected override Task<TResult> InterceptAsync<TResult>(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func<IInvocation, IInvocationProceedInfo, Task<TResult>> proceed)
        {
            throw new NotImplementedException();
        }
    }
}
